package com.jari.lg.service.profile.vehicle;

import com.jari.lg.domain.DevBase;
import com.jari.lg.domain.ScenicSpotNoLocalCarDayEntity;
import com.jari.lg.mapper.ScenicSpotNoLocalCarDayEntityMapper;
import com.jari.lg.utils.BaseData;
import com.jari.lg.utils.Constants;
import com.jari.lg.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class ScenicSpotNoLocalCarDayService {

    @Autowired
    private ScenicSpotNoLocalCarDayEntityMapper scenicSpotNoLocalCarDayEntityMapper;

    /*
    *   每天构造数据
    * */
    public void makeInfo(){
        ScenicSpotNoLocalCarDayEntity entity;
        List<DevBase> devBases = BaseData.checkpointList;
        for(DevBase devBase: devBases){
            entity = generate(devBase);
            scenicSpotNoLocalCarDayEntityMapper.insert(entity);
        }
    }


    private ScenicSpotNoLocalCarDayEntity generate(DevBase devBase){
        ScenicSpotNoLocalCarDayEntity entity = new ScenicSpotNoLocalCarDayEntity();
        entity.setCheckpointcode(devBase.getDevicecode());
        entity.setCheckpointname(devBase.getDevicename());
        entity.setCreator("SYS");
        entity.setGmtcreate(new Date());
        entity.setDatetime(new Date());
        entity.setDatastatus(Constants.DATA_STATUS_ONE);
        entity.setNolocalcarnum(Utils.CAR_NUM.get(Constants.NO_LOCAL));
        entity.setNolocalcarprovince(Utils.makeRandProvince(Utils.makeRandInt(5)));
        return entity;
    }
}
